package com.cjzuji.rental.dao.impl;

import com.cjzuji.rental.controller.order.YouPinController;
import com.cjzuji.rental.dao.RenRZuUserDao;
import com.cjzuji.rental.mapper.OrderUserMapper;
import com.cjzuji.rental.pojo.OrderUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class RenRZuUserDaoImpl implements RenRZuUserDao {
    @Autowired
    OrderUserMapper orderUserMapper;

    private static final Logger logger = LoggerFactory.getLogger(RenRZuUserDaoImpl.class);

    @Override
    @Transactional
    public void save(Map<String,Object> detail, Long orderID,String userName,String userPhone,String userAddress,String userIdcard){
        OrderUser renRZuOrderUser = OrderUser.builder()
                .orderId(orderID)
                .userName(userName)  //收货人
                .mobile(userPhone)
                .province(" ")
                .city(" ")
                .county(" ")
                .address(" ")
                .addressInfo(userAddress)
                .idCard(userIdcard)
                .idCardName(userName)
                .idCardImg(" ")
                .idCardBlackImg("")
                .faceImg("")
                .createTime(new Date())
                .updateTime(new Date())
                .build();
        //logger.info("打印添加参数order_user {}",renRZuOrderUser);
        try {
            orderUserMapper.insert(renRZuOrderUser);
        }catch (Exception e){
            logger.info("订单用户添加错误" + e.getMessage());
            throw e; // 重新抛出，确保事务回滚
        }
    }

}
